script.

  const switchHide = (from, to) => {
    $("."+from).hide();
    $("."+to).show();
  }

  const hideAll = (id) => {
    $("."+id).hide();
  }

  const showAll = (id) => {
    $("."+id).show();
  }

  const show = (cat, id) => {
    hideAll(cat);
    $("#"+cat+"-"+id).show();
  }

  const setText = (cat, id, text) => {
    $("."+cat+"-"+id).text(text);
  }

  const animations = {
    hideAll: () => {
      $("#particles-foreground").hide();
      $("#particles-background").hide();
      $("#push-animation").hide();
      $("#download-animation").hide();
    },
    particles: () => {
      $("#particles-foreground").show();
      $("#particles-background").show();
      $("#push-animation").hide();
      $("#download-animation").hide();
    },
    download: () => {
      $("#download-animation").show();
      $("#push-animation").hide();
      $("#particles-foreground").hide();
      $("#particles-background").hide();
    },
    push: () => {
      $("#push-animation").show();
      $("#download-animation").hide();
      $("#particles-foreground").hide();
      $("#particles-background").hide();
    }
  }

  const views = {
    hideAll: () => hideAll("views"),
    show: (id, animation) => {
      if (id != "working"){
        if (id == "done") {
          $(".ubp-robot").addClass("ubp-robot-side");
          $(".ubp-robot").removeClass("ubp-robot-foot");
        } else {
          $(".ubp-robot").removeClass("ubp-robot-side");
          $(".ubp-robot").addClass("ubp-robot-foot");
        }
        animations.hideAll();
        show("views", id);
        return;
      } else {
        $(".ubp-robot").removeClass("ubp-robot-side");
        $(".ubp-robot").removeClass("ubp-robot-foot");
        show("views", "working");
        switch (animation) {
          case "particles":
            animations.particles()
            break;
          case "download":
            animations.download()
            break;
          case "push":
            animations.push()
            break;
          default:
            animations.hideAll();
        }
      }
    }
  }

  const userText = {
    set: (id, text) => setText("user", id, text),
    remove: id => setText("user", id, "")
  }

  const footer = {
    topText: {
      set: (text, dots) => {
        if (dots) $("#wait-dot").show()
        else $("#wait-dot").hide()
        return $("#footer-top").text(text)
      }
    },
    underText: {
      set: (text) => {
        return $("#footer-bottom").text(text)
      }
    },
    speedText: {
      set: (text) => {
        if (text) return $("#footer-speed").text(" at " + text + " MB/s");
        else return $("#footer-speed").text("");
      }
    }
  }

  const modals = {
    show: modal => {
      $('#'+modal+'-modal').modal('show');
    },
    hide: modal => {
      $('#'+modal+'-modal').modal('hide');
    }
  }

  $("#btn-bugreport").click(() => {
    var title = $("#error-body").text();
    ipcRenderer.send("createBugReport", title);
  });

  $("#btn-exit").click(() => {
    var window = remote.getCurrentWindow();
    window.close();
  });

  $("#help").click(() => {
    ipcRenderer.send("createBugReport", "user-requested bug-report");
  });

  $("#donate").click(() => {
    shell.openExternal("https://ubports.com/donate");
  });

  $("#btn-options-close").click(() => {
    modals.show('install');
  });

  if (process.platform === "win32" && !localStorage.getItem('neverAskForWindowsDrivers')) {
    modals.show('windows-drivers');
  }

  ipcRenderer.on("user:update-available", () => {
    if (global.packageInfo.isSnap) {
      $("#snap-update-instructions").show();
      $("#btn-update-installer").hide();
    } else {
      $("#generic-update-instructions").show();
    }
    modals.show('new-update');
  });
